﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Xml.Linq;
using Common.Constants;
using Common.Interface;
using Common.Helper;

namespace MainProcessor.Processors
{
    public class EntityFactory : IEntityFactory
    {
        public List<IChild> CreateChildren(XElement parentContainer)
        {
            return (from child in parentContainer.Descendants(XmlConstants.Child.ToString())
                  let parent = child.Ancestors(XmlConstants.Child).FirstOrDefault()
                  select new ChildProcessor(child, parent)).AsEnumerable<IChild>().ToList();
        }

        // other  methods to convert XML into usable classes....
    
    }
}
